<form method="post" enctype="multipart/form-data" target="_blank" id="form-order">
    <div class="table-responsive">
        <table class="table table-bordered table-hover">
            <thead>
            <tr>
                <!-- <td style="width: 1px;" class="text-center"> -->
                <!--
                    <input type="checkbox" onclick="$('input[name*=\'selected\']').prop('checked', this.checked);">
                -->    
                <!-- </td> -->
                <td class="text-center" style="background: #e2e8ff;"> </td>
                <td class="text-right">
                    <a href="javascript:sort('goods_id');">ID</a>
                </td>
                <td class="text-left">
                    <a href="javascript:sort('goods_name');">产品名称<span style="color: red;">(点击预览)</span></a>
                </td>
                <td class="text-left">
                    <a href="javascript:sort('sales_sum');">销量</a>
                </td>                                
                <td class="text-left">
                    <a href="javascript:sort('cat_id');">分类</a>
                </td>                
                <td class="text-left">
                    <a href="javascript:sort('shop_price');">价格</a>
                </td>
				<td class="text-left">
				    <a href="javascript:sort('shop_price');">浮价比例</a>
				</td>
				<td class="text-left">
				   浮价价格
				</td>
			
                <td class="text-center">
                    <a href="javascript:sort('prom_sort');">活动排序</a>
                </td>
             
            </tr>
            </thead>
            <tbody>
            <volist name="goodsList" id="list">
                <tr>
                    <td> <input type="checkbox" name="goods_id[]"  value="{$list.goods_id}"> </td>
                    <td class="text-right">{$list.goods_id}
					<input type="hidden" name="shipping_code[]" value="flat.flat">
					</td>
                    <td class="text-left"><img src="{$list.original_img}" height="50" style="cursor: pointer;" onmouseover="layer.tips('<img src={$list.original_img} width=180>',this,{tips: [1, '#EAF8FF']});" onmouseout="layer.closeAll();">  <span onmouseover="layer.tips('关键词:{$list.keywords}',this,{tips: [1, '#000']});" onmouseout="layer.closeAll();"> {$list.goods_name|getSubstr=0,33} <span style="color:red">{$list.huodong}</span></span><i id="yulan" class="fa fa-eye" rel="{$list.goods_id}" style="color: #3c8dbc;cursor: pointer;" title="点击预览"></i></td>
                    <td class="text-center" style="color:#f39c12;">{$list.sales_sum}</td> 
                    <td class="text-left">{$catList[$list[cat_id3]][name]}</td>
                    <td class="text-left">{$list.shop_price}</td>
					<td class="text-left"><input type="text" onchange="updateSort2('goods','goods_id','{$list.goods_id}','floating',this)" onkeyup="this.value=this.value.replace(/[^\d]/g,'')" onpaste="this.value=this.value.replace(/[^\d]/g,'')" maxlength="3" value="{$list.floating}" class="input-sm" style="width: 50px;text-align: center;">%
					</td>
					<td class="text-left" style="color:red;">{:sanwei((float)$list['shop_price']*(float)$list['floating']/100)}</td>
                 
                    
				
                    <td class="text-center">                         
                        <input type="text" onkeyup="this.value=this.value.replace(/[^\d]/g,'')" onpaste="this.value=this.value.replace(/[^\d]/g,'')" onchange="updateSort2('goods','goods_id','{$list.goods_id}','prom_sort',this)" size="4" value="{$list.prom_sort}" />
                    </td>
					
		
                  
                </tr>
            </volist>
            </tbody>
        </table>
    </div>
</form>
<div class="row">
    <div class="navbar-form form-inline" style="float: left;">
        全选
        <input type="checkbox" onclick="$('input[name=\'goods_id\[\]\']').prop('checked', this.checked);">
        <div class="form-group" style="margin-left:20px;">
            <select id="func_id" class="form-control" style="width: 120px;">
                <option value="-1">选择分类</option>
                <foreach name="catListLast" item="v" key="k" >
                    <option value="{$v.cat_id}">{$v.cat_name}</option>
                </foreach>
            </select>
        </div>
        <button id="act_button" type="button" onclick="act_submit();" class="btn btn-primary"><i class="fa"></i>批量分类</button>
    </div>
    <div class="col-sm-9 text-right">{$page}</div>
</div>
<script>
    // 点击分页触发的事件
    $(".pagination  a").click(function(){
        cur_page = $(this).data('p');
        ajax_get_table('search-form2',cur_page);
    });
	
	$(".table-responsive #chakan_kucun").click(function(){
			var myrel=$(this).attr('rel');
			var myrul='/index.php/seller/goods/chakan_kucun/goods_id/'+myrel;//+myrel;
				layer.open({
				  type: 2,
				  title:'产品库存、价格明细',
				  shadeClose: true, //点击遮罩关闭
				  skin: 'layui-layer-rim', //加上边框
				  area: ['90%', '620px'], //宽高
				  content: myrul
			})
	});
	$(".table-responsive #yulan").click(function(){
			var myrel=$(this).attr('rel');
			var myrul='/index.php/Mobile/Goods/goodsInfo/id/'+myrel;//+myrel;
				layer.open({
				  type: 2,
				  title:'产品预览，价格、规格与小程序一致，其他仅供参考',
				  shadeClose: true, //点击遮罩关闭
				  skin: 'layui-layer-rim', //加上边框
				  area: ['550px', '90%'], //宽高
				  content: myrul
			})
	});

    $(".table-responsive #xiugai").click(function(){
        var myrel=$(this).attr('rel');
        var store_id=$(this).attr('rev');
        var myrul='/index.php/Seller/Admin/login/store_id/'+store_id;//+myrel;
        $.get(myrul,function(e){
            layer.open({
                type: 2,
                shadeClose: true, //点击遮罩关闭
                title:'商家产品信息',
                skin: 'layui-layer-rim', //加上边框
                area: ['90%', '90%'], //宽高
                content: myrel
            });
        })
    });

    //获取选中商品id
    function get_select_goods_id_str() {
        if ($('input[name="goods_id\[\]"]:checked').length == 0)
            return false;
        var goods_arr = Array();
        $('input[name="goods_id\[\]"]:checked').each(function () {
            goods_arr.push($(this).val());
        });
        var goods_id_str = goods_arr.join(',');
        return goods_id_str
    }


    //批量操作提交
    function act_submit() {

        //prompt层
        var type = $("#func_id").val();
        var ids = get_select_goods_id_str();
        if (ids == false) {
            layer.alert('请勾选要操作的订单', {icon: 2});
            return;
        }
        if (type == '-1') {
            layer.alert('请选择操作类型', {icon: 2});
            return;
        }


        $.ajax({
            type: "POST",
            url: "/index.php/Seller/goods/goods_actions",
            data: {type: type,goods_ids: ids},
            success: function (data) {
                if(data=='0'){
                    layer.alert('产品修改成功！', {icon: 6},function(e){
                        window.location.reload();
                    });
                }else{
                    layer.alert('系统错误！', {icon: 5});
                }
            },
            error:function(){
                layer.alert('网络异常', {icon: 2,time: 3000});
            }
        });
    }

	// $(".table-responsive #xiugai").click(function(){
	// 		var myrel=$(this).attr('rel');
	// 		var myrul='/index.php/Seller/Goods/addEditGoods/goods_id/'+myrel;//+myrel;
	// 			layer.open({
	// 			  type: 2,
	// 			  title:'产品修改编辑',
	// 			  shadeClose: true, //点击遮罩关闭
	// 			  skin: 'layui-layer-rim', //加上边框
	// 			  area: ['100%', '90%'], //宽高
	// 			  content: myrul
	// 		})
	// });
	// $(".table #picshow").click(function(){
	// 	var mypic=$(this).attr('src');
	// 	  layer.photos({
	// 	    photos: {
	// 			  "data": [
	// 				{
	// 				  "alt": "产品主图",
	// 				  "src": mypic,
	// 				}],
	// 				}
	// 	    ,anim: 5 //0-6的选择，指定弹出图片动画类型，默认随机
	// 	  });
	// });
    /*
     * 清除静态页面缓存
     */
    function ClearGoodsHtml(goods_id)
    {
        $.ajax({
            type:'GET',
            url:"{:U('Admin/System/ClearGoodsHtml')}",
            data:{goods_id:goods_id},
            dataType:'json',
            success:function(data){
                layer.alert(data.msg, {icon: 2});
            }
        });
    }
    /*
     * 清除商品缩列图缓存
     */
    function ClearGoodsThumb(goods_id)
    {
        $.ajax({
            type:'GET',
            url:"{:U('Admin/System/ClearGoodsThumb')}",
            data:{goods_id:goods_id},
            dataType:'json',
            success:function(data){
                layer.alert(data.msg, {icon: 2});
            }
        });
    }
</script>